using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace AUSRIS.Reports.Utilities.Deployment.Entities
{
	/// <summary>
	/// Represents a binary resource to be published,
	/// such as an image file
	/// </summary>
	public class Resource : CatalogFile
	{
		#region Private Fields

		private string mimeType;

		#endregion

		#region Constructor(s)

		public Resource(string name, Folder parentFolder, string sourceFilePath, string mimeType)
			: base(name, parentFolder, sourceFilePath)
		{
			this.mimeType = mimeType;
		}

		#endregion

		#region Properties
	
		public string MimeType
		{
			get
			{
				return mimeType;
			}
		}
		
		#endregion

		#region Public Methods

		public Byte[] GetContents()
		{
			byte[] contents;
			FileInfo fileInfo = new FileInfo(this.SourcePath);
			using ( FileStream stream = fileInfo.OpenRead() )
			{
				long byteLength = stream.Length;
				contents = new byte[byteLength];
				stream.Read(contents, 0, (int)byteLength);
			}
			return contents;
		}

		#endregion
	}
}